﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// Pour en savoir plus sur le modèle d'élément Contrôle utilisateur, consultez la page http://go.microsoft.com/fwlink/?LinkId=234236

namespace BlipSansBlop
{
    public sealed partial class Stats : UserControl
    {
        public static Stats Instance { get; set; }

        public static long Compteur { get; set; }
        public static Boolean Compte { get; set; }

        public Stats()
        {
            this.InitializeComponent();
            Stats.Instance = this;
            Stats.Compteur = 0;
            Stats.Compte = false;
        }


        public static void Update()
        {
            if (Compte)
            {
                Compteur--;
                if (Compteur < 0)
                {
                    Perso.Balles += 100;
                    Compte = false;
                    Compteur = 0;
                }
            }

            if (Perso.Balles > 0) Stats.Instance.Ammo.Text = Perso.Balles.ToString();
            else
            {
                Stats.Instance.Ammo.Text = "Chargeur vide, patientez ...";
                Compte = true;
                Compteur = 2;
            }

            if (Perso.Vie < 6) Stats.Instance.Coeur6.Opacity = 0.3;
            else Stats.Instance.Coeur6.Opacity = 1;

            if (Perso.Vie < 5) Stats.Instance.Coeur5.Opacity = 0.3;
            else Stats.Instance.Coeur5.Opacity = 1;

            if (Perso.Vie < 4) Stats.Instance.Coeur4.Opacity = 0.3;
            else Stats.Instance.Coeur4.Opacity = 1;

            if (Perso.Vie < 3) Stats.Instance.Coeur3.Opacity = 0.3;
            else Stats.Instance.Coeur3.Opacity = 1;

            if (Perso.Vie < 2) Stats.Instance.Coeur2.Opacity = 0.3;
            else Stats.Instance.Coeur2.Opacity = 1;

            if (Perso.Vie < 1) Stats.Instance.Coeur1.Opacity = 0.3;
            else Stats.Instance.Coeur1.Opacity = 1;
        }
    }
}
